﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ADC.DAL;

namespace ADC.BL
{
    public class AboutFactory
    {
        public static About GetAboutType(int type)
        {
            var db = new dbADCEntities();
            var category = db.Categories.Where(c => c.Type == type).FirstOrDefault();
            
            if (category != null)
            {
                category.Abouts.Load();
                return category.Abouts.FirstOrDefault();
            }
            return null;
        }

        public static void UpdateAbout(string title, string  body)
        {
            var db = new dbADCEntities();

            var category = db.Categories.Where(c => c.Type == 1).FirstOrDefault();
            if (category != null)
            {
                
                category.Abouts.Load();
                var about=  category.Abouts.FirstOrDefault();
                about.Body = body;
                about.Title = title;

            }
            db.SaveChanges();
        }
    }
}
